﻿using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace LiteBlog.Common.Entities
{
    public class Tag : IEqualityComparer<Tag>
    {
        [Required(ErrorMessage = "Please enter url name")]
        [RegularExpression(@"^[\S]*$", ErrorMessage = "The url name cannot contain white spaces")]
        public string TagId { get; set; }

        [Required(ErrorMessage = "Please enter display name")]
        public string Name { get; set; }

        public int Count { get; set; }
        public string Class { get; set; }

        public Tag() : this(string.Empty, string.Empty) { }

        public Tag(string tagId, string name)
        {
            TagId = tagId;
            Name = name;
        }

        public bool Equals(Tag x, Tag y)
        {
            return x.TagId.Equals(y.TagId);
        }

        public int GetHashCode(Tag obj)
        {
            return obj.TagId.GetHashCode();
        }

        public static IEqualityComparer<Tag> Comparer
        {
            get
            {
                return new Tag();
            }
        }
    }
}